function getCode() {
    var fromurl = location.href;
    var appid = "wxa5d70c74c24b2c50";
    var url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + encodeURIComponent(fromurl) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
    // var url = 'https://166036.com'
    var code = getUrlValue("code");
    // alert(code)
    if (code) {
        comQuest("get", serverIP + "member/getcode?code=" + code, '', function (res) {
            // alert(JSON.stringify(res));
            if (res.success === true) {
                // alert(JSON.stringify(res.data));
                saveUser(res.data.user);
                saveToken(res.data.token);
                console.log(getToken());
                window.location.href = 'https://166036.com/xm/pages/manual.html';
            }
        })
    } else {
        window.location.href = url;
    }
}

//不要删
var user = getUser();
if (!user || JSON.stringify(user) === '{}') {
    // 正式
    // getCode();
    //开发测试用户登陆
    getCurrUser(280);
}

function getCurrUser(id) {
    $.ajax({
        type: 'post',
        url: serverIP + 'member/testFindOne',
        data: JSON.stringify({id: id}),
        dataType: 'json',
        async: false,
        cache: false,
        headers: {
            'Content-Type': 'application/json;charset=utf-8'
        },
        success: function (res) {
            saveUser(res.data.user);
            saveToken(res.data.token);
            console.log(getToken());
        }
    });
}

